import 'package:flutter/material.dart';

//SimpleDialog等的弹窗控件必须放在showDialog函数中调用才有结果
//弹窗的控件必须要在有状态的控件下才能调用showDialog函数
class Sh extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
  }

}

class Show extends StatefulWidget{
  @override
  Sha createState() => new Sha();
}

/*
class Sha extends State<Show>{
  _showDalog(){
    showDialog(
      context: context,
      builder: (BuildContext context) {
      return new AlertDialog(
        title: new Text('Rewind and remember'),
        content: new SingleChildScrollView(
          child: new ListBody(
            children: <Widget>[
              new Text('You will never be satisfied.'),
              new Text('You\’re like me. I’m never satisfied.'),
            ],
          ),
        ),
        //给AlertDialog添加按钮
        actions: <Widget>[
          new FlatButton(
            child: new Text('Regret'),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
        ],
      );
    },
    );
  }
*/

class Sha extends State<Show>{
  _showDalog(){
    showDialog(
      context: context,
      builder: (BuildContext context) {
      return new SimpleDialog(
        title: const Text('Select assignment'),
        children: <Widget>[
          new SimpleDialogOption(
            onPressed: () { print("object"); },
            child: const Text('Treasury department'),
          ),
          new SimpleDialogOption(
            onPressed: () { print("object"); },
            child: const Text('State department'),
          ),
        ],);
    },
    );
  }


  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Container(
       width: 50.0,
       height: 50.0,
       color: Colors.green,
       child: new RaisedButton(
         color: Colors.blue,
         child: new Text("data"),
         onPressed: _showDalog,
         elevation: 2.0,
         disabledElevation: 0.0,
         highlightElevation: 6.0,
       ),
    );
  }

}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Show()
    );
  }
}

void main() {
  runApp(new MyApp());
}